<template>
  <div class="container">
    <div class="screen" ref="screen">
      <div class="top">
        <Top />
      </div>
      <div class="bottom">
        <div class="left">
          <Tourist class="tourist" />
          <Sex class="sex" />
          <Age class="age" />
        </div>
        <div class="center">
          <Map class="map" />
          <Line class="line" />
        </div>
        <div class="right">
          <rank class="rank" />
          <year class="year" />
          <couter class="couter" />
        </div>
      </div>
    </div>
  </div>
</template>

<script lang="ts" setup>
import { ref, onMounted } from 'vue'
import Top from './compontens/top.vue'
import Age from './compontens/age.vue'
import Sex from './compontens/sex.vue'
import Tourist from './compontens/tourist.vue'
import Map from './compontens/map.vue'
import Line from './compontens/line.vue'
import rank from './compontens/rank.vue'
import year from './compontens/year.vue'
import couter from './compontens/couter.vue'

let screen = ref()

onMounted(() => {
  screen.value.style.transform = `scale(${getScale()}) translate(-50%, -50%)`
})

// 定义大屏缩放比例
function getScale(w = 1920, h = 1080) {
  const ww = window.innerWidth / w
  const hh = window.innerHeight / h
  return ww < hh ? ww : hh
}
// 监听视口的变化
window.onresize = () => {
  screen.value.style.transform = `scale(${getScale()}) translate(-50%, -50%)`
}
</script>

<style scoped lang="scss">
.container {
  width: 100vw;
  height: 100vh;
  background: url(./images/bg.png) no-repeat;
  background-size: 100% 100%;
  // background-size: cover;

  .screen {
    width: 1920px;
    height: 1080px;
    position: fixed;
    // background-color: red;
    left: 50%;
    top: 50%;
    transform-origin: left top;

    .top {
      width: 100%;
      height: 40px;

    }

    .bottom {
      display: flex;

      .left {
        flex: 1;
        height: 1040px;
        display: flex;
        flex-direction: column;

        .tourist {
          flex: 1.5;

        }

        .sex {
          flex: 1;

        }

        .age {
          flex: 1;

        }


      }

      .center {
        flex: 2;
        display: flex;
        margin: 0 20px;
        flex-direction: column;

        .map {
          flex: 3;
        }

        .line {
          flex: 1;
        }
      }

      .right {
        flex: 1;
        display: flex;
        margin-top: 10px;
        flex-direction: column;

        .rank {
          flex: 1.5;
        }

        .year {
          flex: 1;
          margin: 20px 0;
        }

        .couter {
          flex: 1;
        }
      }
    }
  }
}
</style>
